﻿using System.Windows;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.Unity;
using TVersiPlay.MainMenu;
using TVersiPlay.AppSettings;
using TVersiPlay.Common.Interfaces;
using TVersiPlay.Services;
using TVersiPlay.MediaBrowse;


namespace TVersiPlay
{
    class Bootstrapper: UnityBootstrapper
    {
        protected override IModuleCatalog CreateModuleCatalog()
        {
            var catalog = new ModuleCatalog();
            catalog.AddModule(typeof(MainMenuModule))
                   .AddModule(typeof(AppSettingsModule))
                   .AddModule(typeof(MediaBrowseModule));
            //    .AddModule(typeof(NewsModule));

            return catalog;
        }       

        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();         



            this.Container.RegisterType<INavigationService, NavigationService>(new ContainerControlledLifetimeManager());            
            this.Container.RegisterType<IAppSettingsService, AppSettingsService>(new ContainerControlledLifetimeManager());
            this.Container.RegisterType<IUPnPControlPointService, UPnPControlPointService>(new ContainerControlledLifetimeManager());         
           
        }

        protected override void InitializeShell()
        {
            base.InitializeShell();
            //ShellViewModel vm = new ShellViewModel(this.Container);
            Application.Current.MainWindow = (Window)this.Shell;
            Application.Current.MainWindow.Show();

        }

        //protected override void InitializeModules()
        //{
        //    //IEnumerable<IModule> modules = this.Container.GetExportedValues<IModule>();

        //    base.InitializeModules();
        //}

        protected override DependencyObject CreateShell()
        {
            return Container.Resolve<Shell>();
        }

    }
}
